﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpSoft.Documentation.Html
{
    public static class Utility
    {
        /// <summary>
        /// 获取web颜色名称描述对应的颜色值
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static int? GetColorFromWebColorName(string name)
        {
            var str="";
            switch (name.ToLower())
            {
                case "aliceblue":
                    str = "f0f8ff";
                    break;
                case "antiquewhite":
                    str = "faebd7";
                    break;
                case "aquamarine":
                    str = "7fffd4";
                    break;
                case "azure":
                    str = "f0ffff";
                    break;
                case "beige":
                    str = "f5f5dc";
                    break;
                case "bisque":
                    str = "ffe4c4";
                    break;
                case "black":
                    str = "000000";
                    break;
                case "blanchedalmond":
                    str = "ffebcd";
                    break;
                case "blue":
                    str = "0000ff";
                    break;
                case "blueviolet":
                    str = "8a2be2";
                    break;
                case "brown":
                    str = "a52a2a";
                    break;
                case "burlywood":
                    str = "deb887";
                    break;
                case "cadetblue":
                    str = "5f9ea0";
                    break;
                case "chartreuse":
                    str = "7fff00";
                    break;
                case "chocolate":
                    str = "d2691e";
                    break;
                case "coral":
                    str = "ff7f50";
                    break;
                case "cornflowerblue":
                    str = "6495ed";
                    break;
                case "cornsilk":
                    str = "fff8dc";
                    break;
                case "crimson":
                    str = "dc143c";
                    break;
                case "cyan":
                    str = "00ffff";
                    break;
                case "aqua":
                    str = "00ffff";
                    break;
                case "darkblue":
                    str = "00008b";
                    break;
                case "darkcyan":
                    str = "008b8b";
                    break;
                case "darkgoldenrod":
                    str = "b8860b";
                    break;
                case "darkgray":
                    str = "a9a9a9";
                    break;
                case "darkgreen":
                    str = "006400";
                    break;
                case "darkkhaki":
                    str = "bdb76b";
                    break;
                case "darkmagenta":
                    str = "8b008b";
                    break;
                case "darkolivegreen":
                    str = "556b2f";
                    break;
                case "darkorange":
                    str = "ff8c00";
                    break;
                case "darkorchid":
                    str = "9932cc";
                    break;
                case "darkred":
                    str = "8b0000";
                    break;
                case "darksalmon":
                    str = "e9967a";
                    break;
                case "darkseagreen":
                    str = "8fbc8f";
                    break;
                case "darkslateblue":
                    str = "83d8b";
                    break;
                case "darkslategray":
                    str = "f4f4f";
                    break;
                case "darkturquoise":
                    str = "00ced1";
                    break;
                case "darkviolet":
                    str = "0ced1";
                    break;
                case "deeppink":
                    str = "ff1493";
                    break;
                case "deepskyblue":
                    str = "00bfff";
                    break;
                case "dimgray":
                    str = "696969";
                    break;
                case "dodgerblue":
                    str = "1e90ff";
                    break;
                case "firebrick":
                    str = "b22222";
                    break;
                case "floralwhite":
                    str = "fffaf0";
                    break;
                case "forestgreen":
                    str = "228b22";
                    break;
                case "gainsboro":
                    str = "dcdcdc";
                    break;
                case "ghostwhite":
                    str = "f8f8ff";
                    break;
                case "gold":
                    str = "ffd700";
                    break;
                case "goldenrod":
                    str = "daa520";
                    break;
                case "gray":
                    str = "808080";
                    break;
                case "green":
                    str = "008000";
                    break;
                case "greenyellow":
                    str = "f0fff0";
                    break;
                case "hotpink":
                    str = "ff69b4";
                    break;
                case "indianred":
                    str = "cd5c5c";
                    break;
                case "indigo":
                    str = "4b0082";
                    break;
                case "ivory":
                    str = "fffff0";
                    break;
                case "khaki":
                    str = "f0e68c";
                    break;
                case "lavender":
                    str = "e6e6fa";
                    break;
                case "lavenderblush":
                    str = "fff0f5";
                    break;
                case "lawngreen":
                    str = "7cfc00";
                    break;
                case "lemonchiffon":
                    str = "fffacd";
                    break;
                case "lightblue":
                    str = "add8e6";
                    break;
                case "lightcoral":
                    str = "f08080";
                    break;
                case "lightcyan":
                    str = "e0ffff";
                    break;
                case "lightgoldenrodyellow":
                    str = "fafad2";
                    break;
                case "lightgray":
                    str = "d3d3d3";
                    break;
                case "lightgreen":
                    str = "90ee90";
                    break;
                case "lightpink":
                    str = "ffb6c1";
                    break;
                case "lightsalmon":
                    str = "ffa07a";
                    break;
                case "lightseagreen":
                    str = "20b2aa";
                    break;
                case "lightskyblue":
                    str = "87cefa";
                    break;
                case "lightslategray":
                    str = "778899";
                    break;
                case "lightsteelblue":
                    str = "0c4de";
                    break;
                case "lightyellow":
                    str = "ffffe0";
                    break;
                case "lime":
                    str = "00ff00";
                    break;
                case "limegreen":
                    str = "32cd32";
                    break;
                case "linen":
                    str = "faf0e6";
                    break;
                case "magenta":
                    str = "ff00ff";
                    break;
                case "fuchsia":
                    str = "ff00ff";
                    break;
                case "maroon":
                    str = "800000";
                    break;
                case "mediumaquamarine":
                    str = "66cdaa";
                    break;
                case "mediumblue":
                    str = "0000cd";
                    break;
                case "mediumorchid":
                    str = "ba55d3";
                    break;
                case "mediumpurple":
                    str = "9370d8";
                    break;
                case "mediumseagreen":
                    str = "3cb371";
                    break;
                case "mediumslateblue":
                    str = "7b68ee";
                    break;
                case "mediumspringgreen":
                    str = "00fa9a";
                    break;
                case "mediumturquoise":
                    str = "48d1cc";
                    break;
                case "mediumvioletred":
                    str = "c71585";
                    break;
                case "midnightblue":
                    str = "191970";
                    break;
                case "mintcream":
                    str = "f5fffa";
                    break;
                case "mistyrose":
                    str = "ffe4e1";
                    break;
                case "moccasin":
                    str = "ffe4b5";
                    break;
                case "navajowhite":
                    str = "ffdead";
                    break;
                case "navy":
                    str = "000080";
                    break;
                case "oldlace":
                    str = "fdf5e6";
                    break;
                case "olive":
                    str = "808000";
                    break;
                case "olivedrab":
                    str = "6b8e23";
                    break;
                case "orange":
                    str = "ffa500";
                    break;
                case "orangered":
                    str = "ff4500";
                    break;
                case "orchid":
                    str = "da70d6";
                    break;
                case "palegoldenrod":
                    str = "eee8aa";
                    break;
                case "palegreen":
                    str = "98fb98";
                    break;
                case "paleturquoise":
                    str = "afeeee";
                    break;
                case "palevioletred":
                    str = "d87093";
                    break;
                case "papayawhip":
                    str = "ffefd5";
                    break;
                case "peachpuff":
                    str = "ffdab9";
                    break;
                case "peru":
                    str = "cd853f";
                    break;
                case "pink":
                    str = "ffc0cb";
                    break;
                case "plum":
                    str = "dda0dd";
                    break;
                case "powderblue":
                    str = "dda0dd";
                    break;
                case "purple":
                    str = "b0e0e6";
                    break;
                case "red":
                    str = "ff0000";
                    break;
                case "rosybrown":
                    str = "bc8f8f";
                    break;
                case "royalblue":
                    str = "4169e1";
                    break;
                case "saddlebrown":
                    str = "8b4513";
                    break;
                case "salmon":
                    str = "fa8072";
                    break;
                case "sandybrown":
                    str = "f4a460";
                    break;
                case "seagreen":
                    str = "2e8b57";
                    break;
                case "seashell":
                    str = "fff5ee";
                    break;
                case "sienna":
                    str = "a0522d";
                    break;
                case "silver":
                    str = "c0c0c0";
                    break;
                case "skyblue":
                    str = "87ceeb";
                    break;
                case "slateblue":
                    str = "6a5acd";
                    break;
                case "slategray":
                    str = "708090";
                    break;
                case "snow":
                    str = "fffafa";
                    break;
                case "springgreen":
                    str = "00ff7f";
                    break;
                case "steelblue":
                    str = "4682b4";
                    break;
                case "tan":
                    str = "d2b48c";
                    break;
                case "teal":
                    str = "008080";
                    break;
                case "thistle":
                    str = "d8bfd8";
                    break;
                case "tomato":
                    str = "ff6347";
                    break;
                case "turquoise":
                    str = "40e0d0";
                    break;
                case "violet":
                    str = "ee82ee";
                    break;
                case "wheat":
                    str = "f5deb3";
                    break;
                case "white":
                    str = "ffffff";
                    break;
                case "whitesmoke":
                    str = "f5f5f5";
                    break;
                case "yellow":
                    str = "ffff00";
                    break;
                case "yellowgreen":
                    str = "9acd32";
                    break;
                default:
                    return null; 
            }
           return Convert.ToInt32("0x"+str, 16);
        }
    }
}
